<?php
define('ERR_LOGFILE', 'ERROR: Cannot open logfile. (maybe \'chmod 777 tmp\' ?)');
define('ERR_DB', 'ERROR: Cannot open database connection. (check your configs)');
define('ERR_DBQUERY', 'ERROR: Cannot query database. (check your configs)');
require_once 'config.php';
$dbh = mysql_connect($mysqldb['host'], $mysqldb['user'], $mysqldb['pass']);
if(!$dbh) die(ERR_DB);
mysql_select_db($mysqldb['db'], $dbh);
$sql = 'CREATE TABLE signmeup (
		id int not null auto_increment, primary key(id),
		url text,
		user text,
		pass text,
		googlerank int,
		registered int default 0,
		processed int not null default 0
		);';
mysql_query($sql, $dbh) || die(ERR_DBQUERY);
$sql = 'CREATE TABLE capcha (
		id int not null auto_increment, primary key(id),
		url text,
		user text,
		pass text,
		post text,
		host text,
		googlerank int,
		success_string text,
		signmeup_id int
		);';
mysql_query($sql, $dbh) || die(ERR_DBQUERY);
$sql = 'CREATE TABLE status(
			id INT NOT NULL DEFAULT 1,
			total INT NOT NULL DEFAULT 0,
			success INT DEFAULT 0,
			term text,
			query_id  INT DEFAULT -1
		);';
mysql_query($sql, $dbh) || die(ERR_DBQUERY);
echo '<h1>Install complete.</h1>
<br><a href="signmeup.php">Click here to continue</a>';
?>
